package I_Q.hvpcs.boot.vpc.sleeper;

import java.io.IOException;
import java.net.ServerSocket;

import I_Q.hvpcs.boot.sets.StableBlob;

/*
 * 个人著作权人, 作者 罗瑶光, 浏阳
 * yaoguangluo@outlook.com, 313699483@qq.com, 2080315360@qq.com,
 * (lyg.tin@gmail.com2018年回国后因国内G网屏蔽不再使用）
 * 15116110525-浏阳德塔软件开发有限公司-创始人-法人-总经理-永久非盈利-
 * 430181198505250014, G24402609, EB0581342
 * 204925063, 389418686, F2406501, 0626136
 * 湖南省 浏阳市 集里街道 神仙坳社区 大塘冲一段路 208号 阳光家园别墅小区 第十栋别墅 第三层
 * */
public class TimeHall extends Thread implements Runnable {
	public boolean waitingForShake = false;
	private ServerSocket serverSocket;
	private SleeperHall sleeperHall;
	private int maxLimist = 0;

	public void registerServer(ServerSocket server) throws IOException {
		serverSocket = server;
	}

	public void registerSleeperHall(SleeperHall hall) {
		if (null == sleeperHall) {
			this.sleeperHall = hall;
		}
	}

	public TimeHall() {

	}

	public void resetLimists() {
		maxLimist = 70;
	}

	public int getMaxLimist() {
		maxLimist -= 1;
		System.out.flush();
		S_logger.Log.logger.info("" + maxLimist);
		return maxLimist;
	}

	public void run() {
		while (true) {
			try {
				maxLimist = 70;
				Thread.sleep(1000 * 60 * 15);
				if (null != serverSocket) {
					if (null != this.sleeperHall) {
						sleeperHall.callSkivvy();
						StableBlob.checkException();
					}
				}
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}